﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AGE.Rendering;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
namespace AGE.Scene
{
    public static class SceneManager
    {
        public static Scene currentScene;
        private static Color clearColor;
        private static String inspectorString;

        public static void SetClearColor(Color color)
        {
            clearColor = color;
        }

        public static void Load(Scene scene, GraphicsDevice graphicsDevice, ContentManager contentManager)
        {
            currentScene = scene;
            currentScene.Initialize(graphicsDevice);
            currentScene.LoadContent(contentManager);
        }

        public static Scene CurrentScene
        {
            get { return currentScene; }
        }

        public static void Update(float deltaTime)
        {
            currentScene.Update(deltaTime);
        }

        public static void Draw(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch)
        {
            graphicsDevice.Clear(clearColor);
            currentScene.Draw(graphicsDevice, spriteBatch);
        }

        public static string EntityList()
        {
            inspectorString = "";   
            foreach(Entity entity in currentScene.Entities()){

                inspectorString += entity.Name + " " + entity.Transform.Position.ToString() + "\n";
                foreach (AGE.Component.AGEComponent component in entity.Components())
                {
                    inspectorString += "- " + component.GetType()+"\n";
                }
                
                
            }
            return inspectorString;
        }
    }
}
